package tests;

import common.Utils;
import org.openqa.selenium.By;

public class UploadPage extends Utils {
    public static String url = "http://124.223.114.169:8081/upload.html";
    public UploadPage() {
        super(url);
    }

    /**
     * 添加音乐列表没有的音乐——成功上传，跳转至音乐列表页
     */
    public void uploadNew(){
        System.out.println("uploadNew-start");

        driver.findElement(By.cssSelector("body > form > input[type=file]:nth-child(1)")).sendKeys("D:\\MyMusic\\云鬓 - 山鬼_104452.mp3");
        //自定义的保留项：最先删除,保留添加（"D:\MyMusic\云鬓 - 山鬼_104452.mp3"）
        System.out.println("uploadNew-finish");// 思考????note 思考啥来着？？？

    }


    /**
     * 添加音乐列表已有的音乐——提示已经上传过（这个可以和前边那个方法配合测试，前边那个一定是上传过、存在的）
     */
    public void uploadTwice(){
        //
        System.out.println("uploadTwice-start");
        driver.findElement(By.cssSelector("body > form > input[type=file]:nth-child(1)")).sendKeys("D:\\MyMusic\\云鬓 - 山鬼_104452.mp3");
        String exp = driver.findElement(By.cssSelector("body > pre")).getText();
        assert exp.equals("{\"status\":-1,\"message\":\"以经上传过这首了\",\"data\":false}");
        driver.get("http://124.223.114.169:8081/list.html");
        System.out.println("uploadTwice-finish");

    }

}
